using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace BusinessLogic
{
   public  class crReporteEstadisticas 
    {
        //public SeriesCollection getRrtDataEstadisticas(Chart Cht )
        //{
        //    DataEngine de = new DataEngine(ConfigurationManager.ConnectionStrings["ClubConnectionString"].ConnectionString);
        //    de.ChartObject = Cht; // Necessary to view any errors the dataEngine may throw.
        //    de.SqlStatement = GetDataComando();
        //    return de.GetSeries();
        //}


       public String  GetDataComando()
       { String strSQl= "";
        //strSQl = "SELECT TB_SOC_ESI_RegistroIngresoSalida.fechaIngreso as fecha,count(TB_SOC_ESI_Titular_ID) AS NroSocios ";
        //strSQl = strSQl + "FROM TB_SOC_ESI_RegistroIngresoSalida ";
        //strSQl = strSQl + "WHERE TB_SOC_ESI_RegistroIngresoSalida.fechaIngreso >= #STARTDATE# AND TB_SOC_ESI_RegistroIngresoSalida.fechaIngreso <= #ENDDATE# ";
        //strSQl = strSQl + "GROUP BY TB_SOC_ESI_RegistroIngresoSalida.fechaIngreso ";
        //strSQl = strSQl + "ORDER BY TB_SOC_ESI_RegistroIngresoSalida.fechaIngreso ";


        strSQl = "SELECT Fecha,count(N) As NroSocios ";
        strSQl = strSQl + "From (SELECT DATEADD(dd, 0, DATEDIFF(dd, 0, S.fechaIngreso))  as Fecha,1 AS N ";
        strSQl = strSQl + "FROM    dbo.TB_SOC_ESI_RegistroIngresoSalida AS S INNER JOIN  dbo.TB_SOC_ESI_Persona AS P ON ";
        strSQl = strSQl + "s.TB_SOC_ESI_Persona_ID = P.TB_SOC_ESI_Persona_ID INNER JOIN dbo.TB_SOC_ESI_Titular AS T ON ";
        strSQl = strSQl + "T.TB_SOC_ESI_Persona_ID =P.TB_SOC_ESI_Persona_ID ";
        strSQl = strSQl + "GROUP BY P.TB_SOC_ESI_Persona_ID,DATEADD(dd, 0, DATEDIFF(dd, 0, S.fechaIngreso)) ";

        strSQl = strSQl + ") AS T1 ";
        strSQl = strSQl + "WHERE T1.Fecha >= #STARTDATE# AND T1.Fecha <= #ENDDATE# ";
        strSQl = strSQl + "Group BY Fecha ";
        strSQl = strSQl + "Order BY 1 ";
        return strSQl;
       
       }
       

  
    }
}
